package com.lagou.rpc.provider;

import com.lagou.rpc.provider.server.RpcServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


/**
 *基于课上自定义RPC代码中做如下功能实现
 * - 客户端集成spring boot
 * - 客户端提供Controller层,在浏览器发起用户查询功能
 * - 服务端提供2个或2个以上的服务
 * - 客户端完成对服务端的负载轮询调用
 * */
@SpringBootApplication
public class ServerBootstrapApplication implements CommandLineRunner {


    @Autowired
    RpcServer rpcServer;


    public static void main(String[] args) {
        SpringApplication.run(ServerBootstrapApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        new Thread(new Runnable() {
            @Override
            public void run() {
                rpcServer.startServer("127.0.0.1", 0);

            }

        }).start();
    }
}
